/*
定投页面
 */

<template>
  <div>
    <fundation-header :title="'定投'"></fundation-header>
    <div class='mainplan'>
      <group gutter="0">
        <cell-box :border-intent="false" class="firstCellbox">
          <div class="plantInfoTitle">
            <p>{{fundationInfo.proName}}</p>
            <div class="detailInfo"><span>月涨跌幅{{fundationInfo.increase}}</span><span>最新净值{{fundationInfo.lastValue}}</span></div>
          </div>
        </cell-box>
      </group>
      <group gutter="0.2rem">
        <cell class="planCell" title="付款账号" value="6214*******666" @click.native="cardListSelected" is-link ></cell>
        <cell  class="planCell" title="账户余额" >{{balanceNum}}元</cell>
      </group>
      <group>
        <cell class="planCell" v-for="(item,index) in planInfos" :title="item.itemTit" :value="item.val" :key="index" is-link></cell>
        <cell class="planCell" title="期数">
          <div><input type="text" placeholder="请输入" ></div>
        </cell>
      </group>
      <div class="moneyDiv">
        <div class="inputTip">
          <span >请输入购买金额</span>
          <span  class="alertTip" v-if="showTip"><img src="../../assets/img/Fundation/icon_tip.png" class="tipImg"/>账户余额不足</span>
        </div>
          <x-input title="￥"  :type="'number'" placeholder="50000.00元起购" class="moneyInput" @on-change="vertify" v-model="money"></x-input>
          <div  class="introduct" @click="dealIntroduce">交易说明</div>
      </div>
        <x-button @click.native="next" plain type="primary" class="planNextbtn" :class="{'forbiden':isSubmit == false}" :disabled="isSubmit==false">下一步</x-button>
    </div>
  </div>
</template>

<script>
import FundationHeader from './fundationHeader'
import { CellBox } from 'vux'
export default {
  components: {
    FundationHeader,
    CellBox
  },
  data () {
    return {
      fundationInfo: {
        proName: '国泰民安增利债券型发起式C', // 基金名称
        lastValue: '1.0023', // 最新净值
        increase: '5%', // 最新涨幅
        periods: '' // 期数
      },
      balanceNum: '20000', // 余额
      money: '', // 输入的金额
      showTip: false, // 是否提示余额不足
      isSubmit: false, // 标识下一步按钮是否可用
      planInfos: [
        { itemTit: '投资周期：', val: '第2周' },
        { itemTit: '扣款日：', val: '第3日' },
        { itemTit: '期满条件：', val: '成功基数' }
      ]
    }
  },
  created () {},
  methods: {
    // 选择卡片的方法
    cardListSelected () {
      console.log('选择卡片')
    },
    clearInput () {
      this.money = ''
      this.showTip = false
    },
    dealIntroduce () {
      console.log('点击跳转到说明')
      this.$router.push({ name: 'fundationProductDetail' })
    },
    next () {
      this.$router.push({ name: 'planConfirm' })
    },
    vertify () {
      // 检验金额
      let maxMoney = parseFloat(this.balanceNum)
      if (this.money > 0) {
        this.isSubmit = true
      } else {
        this.isSubmit = false
      }
      if (this.money > maxMoney) {
        this.showTip = true
      } else {
        this.showTip = false
      }
    }
  }
}
</script>

<style  lang="less" scoped>
.planCell {
  font-size: 0.28rem;
  padding: 0px 0.29rem 0px 0.31rem;
  color: #333;
  height: 0.9rem;
  input {
    text-align: right;
  }
}
.cellContainer {
  margin: 0;
  height: 5rem;
}
.plantInfoTitle {
  width: 100%;
  height: 1.69rem;
  background: rgba(61, 71, 123, 1);
  color: #fff;
}
.firstCellbox {
  padding: 0;
}
.plantInfoTitle p {
  padding: 0.4rem 0 0.4rem 0.32rem;
  font-size: 0.27rem;
}
.detailInfo {
  line-height: 0.23rem;
}
.detailInfo span {
  box-sizing: border-box;
  display: inline-block;
  width: 50%;
  text-align: center;
  font-size: 0.23rem;
}
.detailInfo span:first-child {
  border-right: 1px solid #eaeaea;
}
.tipImg {
  width: 0.32rem;
  height: 0.32rem;
  vertical-align: middle;
  margin-top: -0.1rem;
  margin-left: 0.3rem;
}
.inputTip {
  font-size: 0.22rem;
  height: 0.61rem;
  line-height: 0.61rem;
  margin-left: 0.29rem;
}
.alertTip {
  color: #ec1b30;
}
.moneyInput {
  overflow: hidden;
  height: 1.2rem;
  font-size: 0.35rem;
  padding-left: 0.32rem;
  background: #ffffff;
  padding-top: 0rem;
  padding-bottom: 0rem;
}
.introduct {
  border-top: 1px solid #eaeaea;
  background: #ffffff;
  font-size: 0.24rem;
  color: #6666ff;
  height: 0.9rem;
  padding: 0 0 0 0.3rem;
  line-height: 0.9rem;
}
.planNextbtn {
  line-height: 0.88rem;
  width: 6.9rem;
  margin-left: 0.3rem;
  margin-top: 0.49rem;
  margin-bottom: 0.5rem;
  background: #ec1b30;
  font-size: 0.3rem;
  border-radius: 0.06rem;
  color: white;
  border-width: 0rem;
  &.forbiden {
    opacity: 0.5;
  }
}
</style>
